/*
 * Copyright (C) 2020 Honeywell, Inc. All Rights Reserved.
 */
package org.thanos.iot.dao.graphic;

import com.honeywell.tj.iot.entity.graphic.GraphicComponent;
import com.honeywell.tj.iot.vo.graphic.GraphicCategoryVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface GraphicComponentMapper {

    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "editable", property = "editable", jdbcType = JdbcType.INTEGER
            )
    })
    @Select("SELECT id, name, editable, width, height FROM iot_graphic_component WHERE category_id = #{categoryId}")
    List<GraphicCategoryVo> selectComponentsByCategoryIdSelective(@Param("categoryId") Integer categoryId);

    List<GraphicComponent> selectComponents();

    @Results({
            @Result(column = "type_id", property = "typeId", jdbcType = JdbcType.INTEGER
            )
    })
    @Select("SELECT type_id FROM iot_graphic_component WHERE id = #{id}")
    Integer selectComponentTypeIdById(@Param("id") Integer id);

    GraphicComponent selectComponentById(@Param("id") Integer id);

    List<GraphicComponent> selectComponentsByCategoryId(@Param("categoryId") Integer categoryId);

    List<GraphicComponent> selectComponentsByCategoryIds(@Param("list") List<Integer> categoryIds);

    int insertComponent(GraphicComponent graphicComponent);

    int updateComponent(GraphicComponent graphicComponent);

    int deleteComponent(@Param("id") Integer id);

    int deleteComponentsByIds(@Param("list") List<Integer> ids);
}
